<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ page import="com.hq.common.utils.BeanUtil" %>
<%@ page import="com.hq.common.utils.ApplicationContextUtils" %>
<%@ page import="com.hq.common.service.WeiboService" %>
<%@ page import="com.hq.common.domain.SearchObject" %>
<%@ page import="com.hq.common.domain.SearchValue" %>
<%@ page import="com.hq.common.domain.Weibo" %>
<%@ page import="com.hq.common.utils.StringUtils" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE html >
<html>
<head>
    <base href="<%=request.getContextPath()%>/">
    <%@ include  file="/modules/common/js/common.jsp"%>
    <link rel="stylesheet" href="./modules/common/css/home.css" type="text/css"/>
    <link rel="stylesheet" href="./modules/common/css/common.css" type="text/css"/>
    <script src="./modules/common/js/home.js"></script>
</head>
<body>
<div class="container">
    <div class="header">
        <div class="logo">
            <img src="./modules/common/images/0712_02.jpg">
        </div>
        <div class="search_bar">
            <div class="fl">
                <a href="<%=request.getContextPath()%>/rest/job/gotoList"><img src="./modules/common/images/0712_04.jpg" width="630"/></a>
            </div>
            <div class="login_item fl">
                <img id="login_btn" src="./modules/common/images/0712_07.jpg"/><img id="register_btn" src="./modules/common/images/0712_08.png"/>
            </div>
        </div>
    </div>
    <div class="menu">
        <div class="menu_list fl">

        </div>
        <div class="ad_list fl">
            <img src="./modules/common/images/0712_05.png" width="744"/>
        </div>
    </div>
    <div class="content">
        <div class="secret">
            <div class="title_bar">
                <span>职场揭秘</span>
            </div>
            <div class="desc">
                <img src="./modules/common/images/0712_06.jpg" />
            </div>
            <div class="custom_wrap">
                <form id="secretForm" action="<%=basePath %>/rest/job/saveJobSecret">
                    <div>
                        <label for="customCompany">公司：</label>
                        <input id="customCompany" name="company" type="text" class="border-text"/>
                    </div>
                    <div>
                        <label for="customMail">邮箱：</label>
                        <input id="customMail" name="mail" type="text" class="border-text"/>
                    </div>
                    <div>
                        <label for="customJob">职位：</label>
                        <input id="customJob" name="station" type="text" class="border-text"/>
                    </div>
                    <div>
                        <label for="customName">姓名：</label>
                        <input id="customName" name="name" type="text" class="border-text"/>
                    </div>
                    <div>
                        <input type="submit" class="custom_btn" value="免费订制揭秘"/>
                    </div>
                </form>
            </div>
        </div>
        <div class="interview">
            <div class="title_bar">
                <span id="hot_interview" class="current">热门群面</span>
                <span id="new_interview">最新群面</span>
            </div>
            <div id="interview_content1">
                <div class="interview_row">
                    <div class="hr_short">
                        <img src="./modules/common/images/hr_pic01.png" title="hr"/>
                        <div class="company_name">贝莱胜</div>
                        <div class="hr_info">
                            <span>超人</span>&nbsp;|&nbsp;<span>em@plexus.com</span>
                        </div>
                        <div class="interview_time">2015年7月19日 10:39AM</div>
                        <div class="interview_status">
                            <div>
                                <span>20</span>人&nbsp;|&nbsp;<span style="color: #ff0000;">15</span><span style="color: #ff0000;">人已入</span>
                            </div>
                            <div class="join_request_btn">申请加入</div>
                        </div>
                    </div>
                    <div>
                        <table class="content_table">
                            <tr>
                                <td class="td01">匹配岗位：</td>
                                <td class="td02"><a>项目工程师></a></td>
                                <td class="td03">持续时间：</td>
                                <td class="td04">30分钟</td>
                            </tr>
                            <tr>
                                <td class="td01">群面形式：</td>
                                <td class="td02">无领导自由讨论</td>
                                <td class="td03">主持观察：</td>
                                <td class="td04">30分钟</td>
                            </tr>
                            <tr>
                                <td class="td01">群面时间：</td>
                                <td class="td02">2015年7月20日 15:00PM</td>
                                <td class="td03">群面结果：</td>
                                <td class="td04">24小时内通知下一轮面试名单</td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="more_wrap"><a class="see_more">查看更多>></a></div>
            </div>
            <div id="interview_content1_footer"></div>
            <div id="interview_content2" style="display: none;">
                <div class="interview_row">
                    <div class="hr_short">
                        <img src="./modules/common/images/hr_pic01.png" title="hr"/>
                        <div class="company_name">福利亚</div>
                        <div class="hr_info">
                            <span>超人</span>&nbsp;|&nbsp;<span>em@plexus.com</span>
                        </div>
                        <div class="interview_time">2015年7月19日 10:39AM</div>
                        <div class="interview_status">
                            <div>
                                <span>20</span>人&nbsp;|&nbsp;<span style="color: #ff0000;">15</span><span style="color: #ff0000;">人已入</span>
                            </div>
                            <div class="join_request_btn">申请加入</div>
                        </div>
                    </div>
                    <div>
                        <table class="content_table">
                            <tr>
                                <td class="td01">匹配岗位：</td>
                                <td class="td02"><a>项目工程师></a></td>
                                <td class="td03">持续时间：</td>
                                <td class="td04">30分钟</td>
                            </tr>
                            <tr>
                                <td class="td01">群面形式：</td>
                                <td class="td02">无领导自由讨论</td>
                                <td class="td03">主持观察：</td>
                                <td class="td04">30分钟</td>
                            </tr>
                            <tr>
                                <td class="td01">群面时间：</td>
                                <td class="td02">2015年7月20日 15:00PM</td>
                                <td class="td03">群面结果：</td>
                                <td class="td04">24小时内通知下一轮面试名单</td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="more_wrap"><a class="see_more">查看更多>></a></div>
            </div>
        </div>
        <div id="interview_content2_footer" style="display: none;"></div>
        <div class="station">
            <div class="title_bar">
                <span id="hot_station" class="current">热门职位</span>
                <span id="new_station">最新职位</span>
            </div>
            <div id="station_content1" class="station_content1">
                <div class="station_row">
                    <table>
                        <tr>
                            <td class="td05"><span class="station_name">项目工程师</span><span class="station_interview">群面进行中>></span></td>
                            <td><span class="station_company">贝莱胜</span><span class="station_addr">厦门/全职</span></td>
                        </tr>
                        <tr>
                            <td class="td05"><span class="station_salary">3K-5K</span>应届毕业生/本科</td>
                            <td>>EMS(电子制造服务)企业</td>
                        </tr>
                        <tr>
                            <td class="td05">职位诱惑：成长空间大</td>
                            <td>>1980年成立,总部在美国,全球N个分公司</td>
                        </tr>
                        <tr>
                            <td class="td05"><span class="station_time">2015年7月19日 11:34AM</span></td>
                            <td>
                                <span class="station_tag">16薪</span>
                                <span class="station_tag">成长空间大</span>
                                <span class="station_tag">同事友好</span>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="more_wrap"><a class="see_more">查看更多>></a></div>
            </div>
            <div id="station_content1_footer" style="display: none;"></div>
            <div id="station_content2" class="station_content1" style="display: none;">
                <div class="station_row">
                    <table>
                        <tr>
                            <td class="td05"><span class="station_name">网页美工</span><span class="station_interview">群面进行中>></span></td>
                            <td><span class="station_company">百度</span><span class="station_addr">厦门/全职</span></td>
                        </tr>
                        <tr>
                            <td class="td05"><span class="station_salary">8K-9K</span>应届毕业生/本科</td>
                            <td>>网络公司</td>
                        </tr>
                        <tr>
                            <td class="td05">职位诱惑：成长空间大</td>
                            <td>>1980年成立,总部在美国,全球N个分公司</td>
                        </tr>
                        <tr>
                            <td class="td05"><span class="station_time">2015年7月19日 11:34AM</span></td>
                            <td>
                                <span class="station_tag">16薪</span>
                                <span class="station_tag">成长空间大</span>
                                <span class="station_tag">同事友好</span>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="more_wrap"><a class="see_more">查看更多>></a></div>
            </div>
            <div id="station_content2_footer" style="display: none;"></div>
        </div>
        <div class="weibo">
            <div class="title_bar">
                <span class="current" id="hot_weibo">热门随手记</span>
                <span id="new_weibo">最新随手记</span>
            </div>
            <div id="weibo_content1" class="weibo_content1">
                <%
                    WeiboService weiboService = ApplicationContextUtils.getBean("weiboService");
                    SearchObject search = new SearchObject(0, 10);
                    SearchValue searchValue = new SearchValue();
                    searchValue.setName("prise");
                    searchValue.setOrder(SearchValue.Order.DESC);
                    search.addCondition(searchValue);
                    search.setPageNum(0);
                    List<Weibo> result_List = weiboService.list(search);
                    if(result_List != null && result_List.size() > 0){
                        String photoUrl = "";
                        for(Weibo weibo : result_List){
                %>
                        <div class="weibo_row">
                            <div class="user_short">
                                <%
                                    photoUrl = weibo.getUser().getPhoto();
                                %>
                                <img src="<%= StringUtils.isEmpty(photoUrl) ? "./modules/common/images/user_pic01.png" : photoUrl%>" title="<%=weibo.getUser().getName()%>"/>
                                <div class="user_name"><%=weibo.getUser().getName()%></div>
                                <div class="user_info">
                                    <span><%=weibo.getUser().getUniversity()%></span>&nbsp;|&nbsp;<span><%=weibo.getUser().getLanguage()%></span>&nbsp;|&nbsp;<span><%=weibo.getUser().getGrade()%></span>
                                </div>
                            </div>
                            <div class="weibo_content"><%=weibo.getContent()%></div>
                            <%
                                if(!StringUtils.isEmpty(weibo.getImg_url())){
                            %>
                            <div class="weibo_img_wrap"><img src="<%=weibo.getImg_url()%>"/></div>
                            <%
                                }
                            %>
                            <div>
                                <span class="weibo_time fl"><%=weibo.getCreate_date()%></span>
                                <span class="weibo_prise fr">赞&nbsp;<%=weibo.getPrise()%></span>
                            </div>
                        </div>
                <%
                        }
                %>
                        <div class="more_wrap"><a class="see_more" href="./modules/user/weiboSearch.jsp">查看更多>></a></div>
                <%
                    }
                %>
            </div>
            <div id="weibo_content2" class="weibo_content2" style="display: none;">
                <%
                    search = new SearchObject(0, 10);
                    searchValue = new SearchValue();
                    searchValue.setName("create_date");
                    searchValue.setOrder(SearchValue.Order.DESC);
                    search.addCondition(searchValue);
                    search.setPageNum(0);
                    result_List = weiboService.list(search);
                    if(result_List != null && result_List.size() > 0){
                        String photoUrl = "";
                        for(Weibo weibo : result_List){
                %>
                <div class="weibo_row">
                    <div class="user_short">
                        <%
                            photoUrl = weibo.getUser().getPhoto();
                        %>
                        <img src="<%= StringUtils.isEmpty(photoUrl) ? "./modules/common/images/user_pic01.png" : photoUrl%>" title="<%=weibo.getUser().getName()%>"/>
                        <div class="user_name"><%=weibo.getUser().getName()%></div>
                        <div class="user_info">
                            <span><%=weibo.getUser().getUniversity()%></span>&nbsp;|&nbsp;<span><%=weibo.getUser().getLanguage()%></span>&nbsp;|&nbsp;<span><%=weibo.getUser().getGrade()%></span>
                        </div>
                    </div>
                    <div class="weibo_content"><%=weibo.getContent()%></div>
                    <%
                        if(!StringUtils.isEmpty(weibo.getImg_url())){
                    %>
                    <div class="weibo_img_wrap"><img src="<%=weibo.getImg_url()%>"/></div>
                    <%
                        }
                    %>
                    <div>
                        <span class="weibo_time fl"><%=weibo.getCreate_date()%></span>
                        <span class="weibo_prise fr">赞&nbsp;<%=weibo.getPrise()%></span>
                    </div>
                </div>
                <%
                    }
                %>
                <div class="more_wrap"><a class="see_more" href="./modules/user/weiboSearch.jsp">查看更多>></a></div>
                <%
                    }
                %>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    $(function(){
        loadNewInterview("interview_content1");
        loadNewInterview("interview_content2");
        loadJobList("station_content1");
        loadJobList("station_content2");
    })
    function loadNewInterview(divId){
        var $search = QSearch.init(wp.config.baseUrl + "/rest/interview/list");
        var $footer = QFooter.init("#" + divId + "_footer", function (pageNum) {
            $search.setPageNum(pageNum);
            $search.doSearch();
        });
        $search.onSearch(function (result) {
            if (handleJsonResponse(result)) {
                var list = result.data["interviewList"],
                        $DOM = $("#" + divId);
                $DOM.html("");
                for (var i = 0, len = list.length; i < len; i += 1) {
                    $DOM.append($("<div>").html(constructInterviewHtml(list[i])));
                }
                $("#" + divId + "_count").html(result.data["totalCount"]);
                $footer.refresh(result.data.pageNum, result.data.pageSize, result.data["totalCount"]);
            }
        });
        if(divId=="interview_content1"){
            $search.addOrderCondition("applyCount","DESC");
        }else{
            $search.addOrderCondition("createTime","DESC");
        }
        $search.doSearch();
    }


    function loadJobList(divId){
        var $search = QSearch.init(wp.config.baseUrl + "/rest/job/list");
        var $footer = QFooter.init("#" + divId + "_footer", function (pageNum) {
            $search.setPageNum(pageNum);
            $search.doSearch();
        });
        $search.onSearch(function (result) {
            if (handleJsonResponse(result)) {
                var list = result.data["jobList"],
                        $DOM = $("#" + divId);
                $DOM.html("");
                for (var i = 0, len = list.length; i < len; i += 1) {
                    $DOM.append($("<div>").html(constructJobHtml(list[i])));
                }
                $("#" + divId + "_count").html(result.data["totalCount"]);
                $footer.refresh(result.data.pageNum, result.data.pageSize, result.data["totalCount"]);
            }
        });
        if(divId=="station_content1"){
            $search.addOrderCondition("applyUserCount","DESC");
        }else{
            $search.addOrderCondition("createTime","DESC");
        }
        $search.doSearch();
    }

    function constructInterviewHtml(interview){
        var html="";
        html+='<div class="interview_row">';
        html+='<div class="hr_short">';
        html+='<img src="'+interview["enterprise"]["logo"]+'" title="hr"/>';
        html+='<div class="company_name">'+interview["enterprise"]["name"]+'</div>';
        html+='<div class="hr_info">';
        html+='<span>'+interview["createUser"]["name"]+'</span>&nbsp;|&nbsp;<span>'+interview["createUser"]["mail"]+'</span>';
        html+='</div>';
        html+='<div class="interview_time">'+interview["createTime"]+'</div>';
        html+='<div class="interview_status">';
        html+='<div>';
        html+='<span>'+interview["applyUserCount"]+'</span>人&nbsp;|&nbsp;<span style="color: #ff0000;">'+interview["passUserCount"]+'</span><span style="color: #ff0000;">人已入</span>';
        html+='</div>';
        html+='<div class="join_request_btn">申请加入</div>';
        html+='</div>';
        html+='</div>';
        html+='<div>';
        html+='<table class="content_table">';
        html+='<tr>';
        html+='<td class="td01">匹配岗位：</td>';
        html+='<td class="td02"><a href="'+wp.config.baseUrl+'/rest/job/'+interview["job"]["id"]+'">'+interview["job"]["name"]+'></a></td>';
        html+='<td class="td03">持续时间：</td>';
        html+='<td class="td04">'+interview["periodTime"]+'分钟</td>';
        html+='</tr>';
        html+='<tr>';
        html+='<td class="td01">群面形式：</td>';
        html+='<td class="td02">无领导自由讨论</td>';
        html+='<td class="td03">主持观察：</td>';
        html+='<td class="td04">30分钟</td>';
        html+='</tr>';
        html+='<tr>';
        html+='<td class="td01">群面时间：</td>';
        html+='<td class="td02">'+interview["beginTime"]+'</td>';
        html+='<td class="td03">群面结果：</td>';
        html+='<td class="td04">'+interview["resultHours"]+'小时内通知下一轮面试名单</td>';
        html+='</tr>';
        html+='</table>';
        html+='</div>';
        html+='</div>';
        return html;
    }

    function constructJobHtml(job){
        var html="";
        html+='<div class="station_row">';
        html+='<table>';
        html+='<tr>';
        html+='<td class="td05"><span class="station_name"><a href="'+wp.config.baseUrl+'/rest/job/'+job["id"]+'">'+job["name"]+'</a></span>';
        if(job["latestInterview"]==null||job["latestInterview"]["status"]==0){
            html+='<span class="station_interview">暂无新群面>></span></td>';
        }else if(job["latestInterview"]["status"]==1||job["latestInterview"]["status"]==2){
            html+='<span class="station_interview"><a href="'+wp.config.baseUrl+'/rest/interview/'+job["latestInterview"]["interviewId"]+'">群面即将进行>></a></span></td>';
        }else if(job["latestInterview"]["status"]==3){
            html+='<span class="station_interview"><a href="'+wp.config.baseUrl+'/rest/interview/'+job["latestInterview"]["interviewId"]+'">群面正在进行>></a></span></td>';
        }
        html+='<td><span class="station_company">'+job["enterprise"]["name"]+'</span><span class="station_addr">'+job["place"]+'/'+param.job.jobType[job["jobType"]]+'</span></td>';
        html+='</tr>';
        html+='<tr>';
        html+='<td class="td05"><span class="station_salary">'+job["minWage"]+'-'+job["maxWage"]+'</span>'+parseJobWorkExp(job["minWorkExp"],job["maxWorkExp"])+'/'+param.job.education[job["education"]]+'</td>';
        html+='<td>>'+job["enterprise"]["intros"][0]+'</td>';
        html+='</tr>';
        html+='<tr>';
        html+='<td class="td05">职位诱惑：'+(job["lure"]==null?"":job["lure"])+'</td>';
        html+='<td>>'+job["enterprise"]["intros"][1]+'</td>';
        html+='</tr>';
        html+='<tr>';
        html+='<td class="td05"><span class="station_time">'+job["createTime"]+'</span></td>';
        html+='<td>';
        for(var tag in job["enterprise"]["tags"]){
            html+='<span class="station_tag">'+job["enterprise"]["tags"][tag]+'</span>';
        }
        html+='</td>';
        html+='</tr>';
        html+='</table>';
        html+='</div>';
        return html;
    }
</script>
</html>